<div class="span12">
  <%= simple_form_for :order, url: admin_terminal_orders_path, method: 'get', html: {class: "form-inline"} do |f| %>
    <label>设备组</label>
    <%= f.input_field :terminal_group_id, selected: params[:order][:terminal_group_id], collection: TerminalGroup.all, label: false, prompt: '请选择设备组' %>
    <label>mac地址</label>
    <%= f.text_field :mac, class: 'input-small', value: params[:order][:mac]%>
    &nbsp;&nbsp;
    <label>地址／车牌号</label>
    <%= f.text_field :address, class: 'input-small', value: params[:order][:address]%>
    &nbsp;&nbsp;
    <label>工单负责人</label>
    <%= f.text_field :worker, class: 'input-small', value: params[:order][:worker]%>
    &nbsp;&nbsp;
    <label>录入时间</label>
    <%= f.text_field :start_date, class: 'ui-date-picker input-small', value: params[:order][:start_date] %> -
    <%= f.text_field :end_date, class: 'ui-date-picker input-small', value: params[:order][:end_date] %>
    <%= f.submit "搜索", :class => "btn"%>
  <% end %>
  <hr/>
  <h5>共有<%= @orders.total_count %>条记录</h5>
</div>
<div class="row-fluid">
  <div class='span10'>
    <table class="table">
      <thead>
        <tr>
          <th>设备名称</th>
          <th>mac地址</th>  
          <th>地址／车牌号</th>
          <th>工单负责人</th>
          <th>录入时间</th>
          <th>操作</th>
        </tr>
      </thead>
      <% @orders.each do |r| %>
        <tr id='order-<%= r.id %>'>
          <td>
            <%= 'Y-BOX' + (r.name == 'yidong' ? '移动版' : '加强版') %>
          </td>
          <td>
            <%= r.terminal.mac %>
          </td>
          <td>
            <%= r.name == 'yidong' ? r.terminal_user.car_license : r.terminal_user.address %>
          </td>
           <td>
            <%= r.worker %>
          </td>
          <td>
            <%= r.created_at.stamp("2013-03-12 22:01:22") %>
          </td>
          <td>
            <%= link_to '编辑', edit_admin_terminal_order_path(r), remote: true if current_admin.can?(edit_admin_terminal_order_path(r)) %>
            <% if r.terminal.terminal_info.blank? %>
              <%= link_to '终端信息', new_admin_terminal_terminal_info_path(r.terminal), remote: true %>
            <% else %>
              <%= link_to '终端信息', edit_admin_terminal_terminal_info_path(r.terminal, r.terminal.terminal_info), remote: true %>
            <% end %>
          </td>
        </tr>
      <% end %>
    </table>
    <%= paginate @orders %>
  </div>
  <div class="span2">
    <div class='content' style="margin-top: 10px">
      <span class="span5 text-right"><a href="<%= export_admin_terminal_orders_path({format: :csv}.merge!(params)) %>" >导出模板</a></span>
    </div>
  </div>
</div>